import com.isaac.MethodService;
import com.isaac.service.MethodServiceThread;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.lang.reflect.Method;
import java.time.Instant;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class MethodServiceConsume {
    public static void main(String[] args) throws InterruptedException {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:dubbo-consumer.xml");
        context.start();


        // 起始调用时间
        long startMills = Instant.now().toEpochMilli();
        ExecutorService executorService = Executors.newFixedThreadPool(3);
        MethodService methodService = context.getBean(MethodService.class);

        for(int i=0; i < 2500; i++){
            executorService.execute(new MethodServiceThread(methodService));
        }

        executorService.shutdown();
        executorService.awaitTermination(3, TimeUnit.MINUTES);



        // 终止时间
        long endMills = Instant.now().toEpochMilli();

        System.out.println("耗时:[" + (endMills-startMills) + "]");
    }
}
